﻿@{
    ViewBag.Title = "CheckOut";
}

@model IEnumerable<GoDinner.Models.GerechtType>

<h1>Bestelling afronden</h1>
<div id="bestelling">
    @Html.Action("GetCartView", "Reservation")
</div>
<br />
<form action="@Url.Action("CheckOut", "Reservation")" method="post">
    <div class="error">@ViewBag.error</div>
    <label for="reservationDate">Datum reservatie:</label>
    <input type="text" name="reservationDate" id="datepicker" class="datefield" />
    <label for="reservationTime">Tijd</label>
    <select name="reservationHour">
        @for (int i = 12; i < 24; i++)
        {
            <option value="@i">@i</option>
        }
    </select>
    <select name="reservationMinute">
        @for (int i = 0; i <= 6; i++)
        {
            <option value="@(i)0">@(i)0</option>
        }
    </select>

    <br /><br />
    <button type="submit">Reservering plaatsen</button>
    <div style="font-size:9pt;">Let op: uw reserving zal pas bevestigd zijn wanneer we contact met u opgenomen hebben.</div>
</form>


@section Scripts{
    <script type="text/javascript">
        $.ajaxSetup({ cache: false });
        $(document).ready(function () {
            $(".datefield").datepicker();
            $(".datefield").datepicker("option", "dateFormat", "dd/mm/yy");
            $(".datefield").datepicker("setDate", new Date());

            $(document).on('click', '.g-remove', function (e) {
                //$('.g-remove').on('click', function () {
                console.log("Test");
                $.ajax({
                    url: '@Url.Action("RemoveGerecht", "Reservation")',
                    data: { gerechtId: $(this).attr('data-id') },
                    type: 'POST',
                    success: function (data) {
                        getShoppingCart();
                    },
                    cache: false
                });
                return false;
            });

            function getShoppingCart() {
                $.ajax({
                    url: '@Url.Action("GetCartView", "Reservation")',
                    dataType: 'html',
                    success: function (data) {
                        $('#bestelling').html(data);
                    }
                })
            }
        });
    </script>
}